﻿import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import './plugins/element.js'
// 引入字体的文件
import './assets/font/iconfont.css'
// 引入全局的样式文件
import './assets/css/global.less'
import '@/assets/fonts/iconfont.css'
// 全局配置表格树形插件
import TreeTable from 'vue-table-with-tree-grid'
// 全局配置axios
import axios from 'axios'

// 全局配置富文本编辑器
import VueQuillEditor from 'vue-quill-editor'

// 富文本编辑器要用到的
import 'quill/dist/quill.core.css' // import styles
import 'quill/dist/quill.snow.css' // for snow theme
import 'quill/dist/quill.bubble.css' // for bubble theme

const service = axios.create({
  baseURL: 'http://dshtweb.zhubin.ink/api/',
  timeout: 1000
})
// 将axios挂载到Vue的原型对象上
// 在别的组件中 this.$http
Vue.prototype.$httpp = service

Vue.use(VueQuillEditor)

// axios基本地址
axios.defaults.baseURL = 'http://dsht.zhubin.ink/api/private/v1/'
// 请求拦截，添加token
axios.interceptors.request.use(config => {
  config.headers.Authorization = window.sessionStorage.getItem('token')
  // console.log(config)
  return config
})
// 全局挂载
Vue.prototype.$http = axios
Vue.prototype.$echarts = window.echarts
// 配置全局时间过滤器
Vue.filter('dataformat', newDate => {
  const dates = new Date(newDate)
  const y = dates.getFullYear()
  const m = (dates.getMonth() + 1 + '').padStart(2, '0')
  const d = (dates.getDate() + '').padStart(2, '0')
  const hh = (dates.getHours() + '').padStart(2, '0')
  const mm = (dates.getMinutes() + '').padStart(2, '0')
  const ss = (dates.getSeconds() + '').padStart(2, '0')
  return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
})

Vue.component('tree-table', TreeTable)
Vue.config.productionTip = false

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
